<style>
	.content {
		position: relative;
		z-index: 1;
		overflow: hidden;
	}

	.content-body {
		position: relative;
	}

	.content-bg {
		position: fixed;
		width: 750rpx;
		height: 1624rpx;
	}

	.gd-top {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 112rpx;
		margin-right: 116rpx;
		justify-content: center;
		padding-top: 98rpx;
	}

	.gd-top-logo {
		width: 158rpx;
		height: 156rpx;
		flex-shrink: 0;
	}

	.gd-top-right {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		position: relative;
		left: -20rpx;
	}

	.gd-top-right-title {
		font-weight: bold;
		font-size: 28rpx;
		color: #160A0A;
	}

	.gd-top-right-ba {
		font-weight: bold;
		font-size: 24rpx;
		color: #160A0A;
	}

	.gd-top-right-btn {
		width: 152rpx;
		height: 52rpx;
		background: rgba(255, 255, 255, 0.56);
		border-radius: 12rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		margin-top: 4rpx;
	}

	.gd-top-right-btn-text {
		font-weight: bold;
		font-size: 24rpx;
		color: #8C3100;
	}

	.gd-tips {
		margin: 10rpx 90rpx 0 92rpx;
		background-image: url('@/static/tipsBg.png');
		background-size: 100% 100%;
		background-repeat: no-repeat;
		display: flex;
		flex-direction: row;
		justify-content: center;
		height: 74rpx;
		padding-top: 14rpx;
		box-sizing: border-box;
	}

	.gd-tips-text {
		font-weight: bold;
		font-size: 24rpx;
		color: #FFEADE;
		line-height: 28rpx;
	}

	.gd-step {
		background-color: #fff;
		border-radius: 20rpx;
		margin: 0 32rpx;
		padding: 24rpx;
		display: flex;
		flex-direction: column;
	}

	.gd-step-title {
		display: flex;
		flex-direction: row;
		align-items: center;
		position: relative;
	}

	.gd-step-title-text {
		font-weight: bold;
		font-size: 28rpx;
		color: #160A0A;
	}

	.gd-step-title-must {
		font-weight: bold;
		font-size: 28rpx;
		color: #FF0000;
	}

	.gd-step-line {
		height: 70rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
		box-sizing: border-box;
		background: #F2F6F8;
		margin-top: 8rpx;
		border-radius: 8rpx;
	}

	.gd-step-input {
		font-size: 24rpx;
		color: #160A0A;
		flex: 1;
	}

	.gd-step-input--placeholder {
		color: #A4A4A4;
		font-size: 24rpx;
	}

	.mt-16 {
		margin-top: 16rpx;
	}

	.gd-step-vector {
		width: 32rpx;
		height: 32rpx;
	}

	.gd-agree {
		margin: 20rpx 0 0 56rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.gd-agree-icon {
		width: 40rpx;
		height: 40rpx;
		margin-right: 12rpx;
	}

	.gd-agree-text {
		font-weight: 500;
		font-size: 24rpx;
		color: #FFFFFF;
	}

	.gd-step-title-tips {
		font-weight: 500;
		font-size: 24rpx;
		color: #FC7B2C;
	}

	.gd-step-idcard {
		width: 300rpx;
		height: 186rpx;
		position: relative;
	}

	.gd-step-idcard-mask {
		position: absolute;
		left: 0;
		top: 0;
		width: 300rpx;
		height: 186rpx;
		z-index: 2;
	}

	.gd-step-block {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		margin-top: 16rpx;
	}

	.gd-step-idcard-item {
		width: 300rpx;
		height: 186rpx;
		position: relative;
		z-index: 1;
	}

	.gd-empty {
		height: 100rpx;
	}

	.gd-btn-box {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		margin: 0 76rpx;
		margin-top: 32rpx;
	}

	.gd-btn-small {
		flex: 1;
		background-color: #fdd637;
		border-radius: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 88rpx;
	}

	.gd-btn {
		width: 400rpx;
		margin-left: 24rpx;
		background-color: #fdd637;
		border-radius: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 88rpx;
	}

	.gd-btn-text {
		font-weight: bold;
		font-size: 32rpx;
		color: #301009;
	}

	.gd-step-image {}

	.gd-step-image-top {
		margin: 0 24rpx;
		margin-top: 20rpx;
		background: #FFFCF3;
		border-radius: 12rpx;
		padding: 24rpx 16rpx;
	}

	.gd-step-image-top-text {
		font-weight: 500;
		font-size: 20rpx;
		color: #FC7B2C;
	}

	.gd-step-image-box {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		column-gap: 20rpx;
		margin-top: 20rpx;
	}

	.gd-step-image-box-item {
		width: 160rpx;
		height: 160rpx;
		border-radius: 12rpx;
	}
</style>

<template>
	<view v-if="showPage" class="content" :style="{height: windowHeight + 'px'}">
		<image src="@/static/bg.png" class="content-bg"></image>
		<scroll-view :style="{height: windowHeight + 'px'}" scroll-y>
			<view class="content-body">
				<view class="gd-top">
					<image src="@/static/logo.png" class="gd-top-logo"></image>
					<view class="gd-top-right">
						<text class="gd-top-right-title">哈尔滨甜夜网络科技有限公司</text>
						<text class="gd-top-right-ba">黑ICP备2020005269号-2</text>
						<view class="gd-top-right-btn">
							<text class="gd-top-right-btn-text">相关资质</text>
						</view>
					</view>
				</view>
				<view class="gd-tips">
					<text class="gd-tips-text">卖家填写以下信息后，即可开始换绑，坐等收钱！</text>
				</view>
				<!-- step1 -->
				<view class="gd-step mt-16" v-if="step == 1">
					<!-- 游戏账号 -->
					<view class="gd-step-title">
						<text class="gd-step-title-text">游戏账号</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<view class="gd-step-line">
						<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
							placeholder="请填写您要出售的游戏账号(QQ/微信/邮箱等)" v-model="form.account" />
					</view>
					<!-- 游戏名 -->
					<view class="gd-step-title mt-16">
						<text class="gd-step-title-text">游戏名称</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<picker mode="selector" :range="gameOptions" range-key="name" :value="form.gameId"
						@change="gameOptionsChange">
						<view class="gd-step-line">
							<text class="gd-step-input"
								:style="{color: form.gameId !== null ? '#160a0a' : '#a4a4a4'}">{{getGameName()}}</text>
							<image src="@/static/vector.png" class="gd-step-vector"></image>
						</view>
					</picker>
					<!-- 账号来源 -->
					<view class="gd-step-title mt-16">
						<text class="gd-step-title-text">账号来源</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<picker mode="selector" :range="accountSourceOptions" range-key="name" :value="form.accountSource"
						@change="accountSourceOptionsChange">
						<view class="gd-step-line">
							<text class="gd-step-input"
								:style="{color: form.accountSource !== null ? '#160a0a' : '#a4a4a4'}">{{getAccountSourceName()}}</text>
							<image src="@/static/vector.png" class="gd-step-vector"></image>
						</view>
					</picker>
					<!-- 是否能对账号安全负责 -->
					<view class="gd-step-title mt-16">
						<text class="gd-step-title-text">是否能对账号安全负责</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<picker mode="selector" :range="safetyOptions" range-key="name" :value="form.safetyOptions"
						@change="safetyOptionsChange">
						<view class="gd-step-line">
							<text class="gd-step-input"
								:style="{color: form.safety !== null ? '#160a0a' : '#a4a4a4'}">{{getSafetyName()}}</text>
							<image src="@/static/vector.png" class="gd-step-vector"></image>
						</view>
					</picker>
					<!-- 交易金额 -->
					<view class="gd-step-title mt-16">
						<text class="gd-step-title-text">交易金额</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<view class="gd-step-line">
						<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
							placeholder="请填写买家给您开出的价格" v-model="form.money" />
					</view>
				</view>
				<!-- step2 -->
				<view class="gd-step" v-if="step == 2">
					<!-- 上传身份证照片 -->
					<view class="gd-step-title">
						<text class="gd-step-title-text">请上传身份证照片</text>
						<text class="gd-step-title-must">*</text>
						<text class="gd-step-title-tips">提示：请上传有效期内的身份证</text>
					</view>
					<view class="gd-step-block">
						<view class="gd-step-idcard">
							<image v-if="!form.idImageFont" src="@/static/rx.png" class="gd-step-idcard-item"></image>
							<image v-else :src="form.idImageFont" class="gd-step-idcard-item">
							</image>
							<view class="gd-step-idcard-mask" @click="uploadIdCard(1)"></view>
						</view>
						<view class="gd-step-idcard">
							<image v-if="!form.idImageBack" src="@/static/gh.png" class="gd-step-idcard-item"></image>
							<image v-else :src="form.idImageBack" class="gd-step-idcard-item">
							</image>
							<view class="gd-step-idcard-mask" @click="uploadIdCard(2)"></view>
						</view>
					</view>
					<!-- 姓名 -->
					<view class="gd-step-title mt-16">
						<text class="gd-step-title-text">姓名</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<view class="gd-step-line">
						<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
							placeholder="请填写姓名" v-model="form.sellerName" />
					</view>
					<!-- 身份证号码 -->
					<view class="gd-step-title mt-16">
						<text class="gd-step-title-text">身份证号码</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<view class="gd-step-line">
						<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
							placeholder="请填写身份证号码" v-model="form.idCardNumber" />
					</view>
					<view class="gd-step-title mt-16">
						<text class="gd-step-title-text">身份证地址</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<view class="gd-step-line">
						<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
							placeholder="请填写身份证地址" v-model="form.idCardAddress" />
					</view>
				</view>
				<view class="gd-step" v-if="step == 2" style="margin-top: 16rpx;">
					<!-- 手机号 -->
					<view class="gd-step-title">
						<text class="gd-step-title-text">手机号</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<view class="gd-step-line">
						<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
							placeholder="请填写您本人实名的常用手机号" v-model="form.primaryPhone" />
					</view>
					<!-- 备用手机号 -->
					<view class="gd-step-title mt-16">
						<text class="gd-step-title-text">备用手机号</text>
					</view>
					<view class="gd-step-line">
						<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
							placeholder="如有其他手机号码请一并填写" v-model="form.secondaryPhone" />
					</view>
				</view>
				<view class="gd-step" v-if="step == 2" style="margin-top: 16rpx;">
					<!-- 网购订单截图 -->
					<view class="gd-step-title">
						<text class="gd-step-title-text">网购订单截图</text>
						<text class="gd-step-title-must">*</text>
					</view>
					<view class="gd-step-image">
						<view class="gd-step-image-top">
							<text class="gd-step-image-top-text">温馨提示：请上传您常住地址6个月内的网购/ 外卖订单截图(如美团1京东/淘宝/拼多多等)，
								购买商品不能为虚拟商品，收货地址不得为网吧 /酒店等非居住性场所</text>
						</view>
						<view class="gd-step-image-box">
							<image v-if="form.orderImageUrl.length < 1" src="@/static/upload.png"
								class="gd-step-image-box-item" @click="uploadImage(null)"></image>
							<image :src="item" v-for="(item,index) in form.orderImageUrl" :key="index"
								class="gd-step-image-box-item" @click="uploadImage(index)"></image>
						</view>
					</view>
				</view>
				<view class="gd-step" v-if="step == 2 && form.gameId !== null && gameOptions[form.gameId].id == 14"
					style="margin-top: 16rpx;">
					<!-- 微信主页面截图 -->
					<view class="gd-step-title">
						<text class="gd-step-title-text">微信主页面截图</text>
						<text class="gd-step-title-must">*</text>
						<text style="position: absolute;right: 24rpx;font-size: 24rpx;color: #FC7B2C;"
							@click="previewExp">查看示例图</text>
					</view>
					<view class="gd-step-image">
						<view class="gd-step-image-box">
							<image v-if="!form.realNameImage" src="@/static/upload.png" class="gd-step-image-box-item"
								@click="uploadRealNameImage"></image>
							<image :src="form.realNameImage" class="gd-step-image-box-item"
								@click="uploadRealNameImage">
							</image>
						</view>
					</view>
				</view>
				<!-- step3 -->
				<template v-if="step == 3">
					<view class="gd-step"
						style="background: linear-gradient(to bottom , #FFBABA 0%, #FFFFFF 100%);margin-top: 16rpx;">
						<!-- 收款账号 -->
						<view class="gd-step-title">
							<text class="gd-step-title-text">收款账号</text>
							<text class="gd-step-title-must">*</text>
						</view>
						<view class="gd-step-line" style="background-color: #ffffff;">
							<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
								placeholder="请填写您本人实名的支付宝账号/银行卡号" v-model="form.paymentAccount" />
						</view>
					</view>
					<view v-if="form.gameId !== null && gameOptions[form.gameId].id != 14" class="gd-step"
						style="background: linear-gradient(to bottom , #FFEBAD 0%, #FFFFFF 100%);margin-top: 16rpx;">
						<view style="display: flex;flex-direction: row;justify-content: space-between;">
							<!-- 联系人与您的关系 -->
							<view style="display: flex;flex-direction: column;">
								<view class="gd-step-title mt-16">
									<text class="gd-step-title-text">联系人与您的关系</text>
									<text class="gd-step-title-must">*</text>
								</view>
								<picker mode="selector" :range="parentsRelOptions" range-key="name"
									:value="form.parentsRel" @change="parentsRelOptionsChange">
									<view class="gd-step-line" style="background-color: #ffffff;">
										<text class="gd-step-input"
											:style="{color: form.parentsRel !== null ? '#160a0a' : '#a4a4a4'}">{{getParentsRelName()}}</text>
										<image src="@/static/vector.png" class="gd-step-vector"></image>
									</view>
								</picker>
							</view>
							<!-- 第一联系人姓名 -->
							<view style="display: flex;flex-direction: column;">
								<view class="gd-step-title mt-16">
									<text class="gd-step-title-text">第一联系人姓名</text>
									<text class="gd-step-title-must">*</text>
								</view>
								<view class="gd-step-line" style="background-color: #ffffff;">
									<input class="gd-step-input" placeholder-class="gd-step-input--placeholder"
										type="text" placeholder="请填写联系人真实姓名" v-model="form.parentsName" />
								</view>
							</view>
						</view>
						<!-- 联系人手机号 -->
						<view class="gd-step-title mt-16">
							<text class="gd-step-title-text">联系人手机号</text>
							<text class="gd-step-title-must">*</text>
						</view>
						<view class="gd-step-line" style="background-color: #ffffff;">
							<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
								placeholder="请填写联系人常用手机号" v-model="form.parentsContact" />
						</view>
					</view>

					<view v-if="form.gameId !== null && gameOptions[form.gameId].id != 14" class="gd-step"
						style="background: linear-gradient(to bottom , #CCF2FF 0%, #FFFFFF 100%);margin-top: 16rpx;">
						<view style="display: flex;flex-direction: row;justify-content: space-between;">
							<!-- 联系人与您的关系 -->
							<view style="display: flex;flex-direction: column;">
								<view class="gd-step-title mt-16">
									<text class="gd-step-title-text">联系人与您的关系</text>
									<text class="gd-step-title-must">*</text>
								</view>
								<picker mode="selector" :range="friendsRelOptions" range-key="name"
									:value="form.friendsRel" @change="friendsRelOptionsChange">
									<view class="gd-step-line" style="background-color: #ffffff;">
										<text class="gd-step-input"
											:style="{color: form.friendsRel !== null ? '#160a0a' : '#a4a4a4'}">{{getFriendsRelName()}}</text>
										<image src="@/static/vector.png" class="gd-step-vector"></image>
									</view>
								</picker>
							</view>
							<!-- 第二联系人姓名 -->
							<view style="display: flex;flex-direction: column;">
								<view class="gd-step-title mt-16">
									<text class="gd-step-title-text">第二联系人姓名</text>
									<text class="gd-step-title-must">*</text>
								</view>
								<view class="gd-step-line" style="background-color: #ffffff;">
									<input class="gd-step-input" placeholder-class="gd-step-input--placeholder"
										type="text" placeholder="请填写联系人真实姓名" v-model="form.friendsName" />
								</view>
							</view>
						</view>
						<!-- 联系人手机号 -->
						<view class="gd-step-title mt-16">
							<text class="gd-step-title-text">联系人手机号</text>
							<text class="gd-step-title-must">*</text>
						</view>
						<view class="gd-step-line" style="background-color: #ffffff;">
							<input class="gd-step-input" placeholder-class="gd-step-input--placeholder" type="text"
								placeholder="请填写联系人常用手机号" v-model="form.friendsContact" />
						</view>
					</view>
				</template>
				<!-- ageree -->
				<view class="gd-agree" v-if="step == 3">
					<image src="@/static/agree.png" class="gd-agree-icon"></image>
					<text class="gd-agree-text">我承诺以上信息真实有效</text>
				</view>
				<!-- btn -->
				<view class="gd-btn-box">
					<view v-if="step > 1" class="gd-btn-small" @click="stepClick(2)">
						<text class="gd-btn-text">上一步</text>
					</view>
					<view :style="{width: step > 1 ? '400rpx' : '598rpx',marginLeft: step > 1 ? '24rpx' :'0'}"
						class="gd-btn" @click="stepClick(1)">
						<text class="gd-btn-text">{{getStepBtnName()}}</text>
					</view>
				</view>
				<view class="gd-empty">

				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		getGameArea,
		getOrderDetail,
		scanIdCard,
		scanIdCard2,
		sellerFill,
		sellerSubmit
	} from '@/network/modules/api.js'
	export default {
		data() {
			return {
				url: 'https://bp.api.10417.com',
				// url: 'http://api.taoqiyou.com:17486',
				windowHeight: 0,
				form: {
					account: null,
					accountSource: null,
					gameId: null,
					safety: null,
					money: null,
					idImageFont: null,
					idImageBack: null,
					sellerName: null,
					idCardNumber: null,
					idCardAddress: null,
					primaryPhone: null,
					secondaryPhone: null,
					orderImageUrl: [],
					paymentAccount: null,
					parentsName: null,
					parentsContact: null,
					parentsRel: null,
					friendsName: null,
					friendsContact: null,
					friendsRel: null,
					inputMethod: 0,
					realNameImage: null
				},
				step: 1,
				gameOptions: [],
				accountSourceOptions: [{
						id: 0,
						name: '自己注册'
					},
					{
						id: 1,
						name: '其他平台购买'
					}
				],
				safetyOptions: [{
						id: 1,
						name: '是'
					},
					{
						id: 2,
						name: '否'
					}
				],
				parentsRelOptions: [{
						id: 0,
						name: '您的母亲'
					},
					{
						id: 1,
						name: '您的父亲'
					}
				],
				friendsRelOptions: [{
						id: 0,
						name: '您的母亲'
					},
					{
						id: 1,
						name: '您的父亲'
					},
					{
						id: 2,
						name: '您的亲戚'
					},
					{
						id: 3,
						name: '您的朋友'
					}
				],
				showPage: false,
				loading: false
			}
		},
		onLoad(options) {
			this.windowHeight = uni.getSystemInfoSync().windowHeight;
			if (options.k) {
				this.form.orderId = options.k;
				getOrderDetail(this.form.orderId).then(res => {
					// setForm
					this.showPage = true;
					this.getGameOptions(res[1].data);
				})
			}
		},
		methods: {
			delEmpty(value) {
				return value.replace(/\s+/g, '')
			},
			// 回显缓存
			setForm(order) {
				if (order.account !== null) {
					this.form.account = this.delEmpty(order.account)
				}
				if (order.accountSource !== null && order.accountSource !== undefined) {
					this.form.accountSource = this.accountSourceOptions.findIndex(el => el.id == order.accountSource);
				}
				if (order.gameId !== null && order.gameId !== undefined && order.gameId) {
					let findIndex = this.gameOptions.findIndex(el => el.id == order.gameId);
					this.form.gameId = findIndex === -1 ? null : findIndex;
				}
				if (order.money !== null) {
					this.form.money = order.money;
				}
				if (order.idImageUrl) {
					let list = order.idImageUrl.split(',');
					this.form.idImageFont = list[0] || null;
					this.form.idImageBack = list[1] || null;
				}
				if (order.sellerName) {
					this.form.sellerName = order.sellerName;
				}
				if (order.idCardNumber) {
					this.form.idCardNumber = order.idCardNumber;
				}
				if (order.idCardAddress) {
					this.form.idCardAddress = order.idCardAddress;
				}
				if (order.primaryPhone) {
					this.form.primaryPhone = order.primaryPhone;
				}
				if (order.secondaryPhone) {
					this.form.secondaryPhone = order.secondaryPhone;
				}
				if (order.orderImageUrl) {
					this.form.orderImageUrl = order.orderImageUrl.split(',');
				}
				if (order.realNameImage) {
					this.form.realNameImage = order.realNameImage;
				}
				if (order.paymentAccount) {
					this.form.paymentAccount = order.paymentAccount;
				}
				if (order.parentsName) {
					this.form.parentsName = order.parentsName;
				}
				if (order.parentsContact) {
					this.form.parentsContact = order.parentsContact;
				}
				if (order.parentsRel !== null && order.parentsRel !== undefined) {
					this.form.parentsRel = this.parentsRelOptions.findIndex(el => el.id == order.parentsRel);
				}
				if (order.friendsName) {
					this.form.friendsName = order.friendsName;
				}
				if (order.friendsContact) {
					this.form.friendsContact = order.friendsContact;
				}
				if (order.friendsRel !== null && order.friendsRel !== undefined) {
					this.form.friendsRel = this.friendsRelOptions.findIndex(el => el.id == order.friendsRel);
				}
				this.form.inputMethod = 0;
			},
			// 按钮
			getStepBtnName() {
				if (this.step == 1) {
					return '下一步（1/3）';
				} else if (this.step == 2) {
					return '下一步（2/3）';
				} else if (this.step == 3) {
					return '提交';
				}
			},
			// 按钮点击
			stepClick(type) {
				if (this.loading) return;
				this.loading = true;
				if (type == 1) {
					if (this.step == 1 || this.step == 2) {
						if (this.step == 1) {
							// 校验
							if (!this.delEmpty(this.form.account)) {
								uni.showToast({
									title: '请填写您要出售的游戏账号(QQ/微信/邮箱等)',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (this.form.gameId === null) {
								uni.showToast({
									title: '请选择游戏',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (this.form.accountSource === null) {
								uni.showToast({
									title: '请选择账号来源',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (this.form.safety === null) {
								uni.showToast({
									title: '请选择是否能对账号安全负责',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.form.money) {
								uni.showToast({
									title: '请填写买家给您开出的价格',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (this.safetyOptions[this.form.safety].id == 2) {
								uni.showToast({
									title: '请对账号安全负责',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							// 第一步点击下一步 缓存数据
							let formData = {
								orderId: this.form.orderId,
								account: this.delEmpty(this.form.account),
								accountSource: this.accountSourceOptions[this.form.accountSource].id,
								gameId: this.gameOptions[this.form.gameId].id,
								safety: this.form.safety,
								money: this.form.money,
								inputMethod: 0,
							}

							sellerFill(formData).then(res => {
								this.step++;
								this.loading = false;
							}).catch(err => {
								this.loading = false;
							})
						} else if (this.step == 2) {
							// 校验
							if (!this.form.idImageFont) {
								uni.showToast({
									title: '请上传身份证正面照',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.form.idImageBack) {
								uni.showToast({
									title: '请上传身份证背面照',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.form.sellerName) {
								uni.showToast({
									title: '请填写姓名',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.isName(this.form.sellerName)) {
								uni.showToast({
									title: '请填写正确的姓名',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.form.idCardNumber) {
								uni.showToast({
									title: '请填写身份证号码',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.form.idCardAddress) {
								uni.showToast({
									title: '请填写身份证地址',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.form.primaryPhone) {
								uni.showToast({
									title: '请填写您本人实名的常用手机号',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.isPhone(this.form.primaryPhone)) {
								uni.showToast({
									title: '请填写正确的常用手机号',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (this.form.orderImageUrl.length < 1) {
								uni.showToast({
									title: '请上传一张网购订单截图',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (this.form.gameId !== null && this.gameOptions[this.form.gameId].id == 14 && !this.form
								.realNameImage) {
								uni.showToast({
									title: '请上传一张微信主页面截图',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							// 第二步点击下一步 缓存数据
							let formData = {
								orderId: this.form.orderId,
								sellerName: this.form.sellerName,
								idCardNumber: this.form.idCardNumber,
								idCardAddress: this.form.idCardAddress,
								idImageUrl: [this.form.idImageFont, this.form.idImageBack].join(','),
								primaryPhone: this.form.primaryPhone,
								secondaryPhone: this.form.secondaryPhone,
								inputMethod: 0,
								orderImageUrl: this.form.orderImageUrl.join(','),
								realNameImage: this.form.realNameImage
							}

							sellerFill(formData).then(res => {
								this.step++;
								this.loading = false;
							}).catch(err => {
								this.loading = false;
							})
						}

					} else if (this.step == 3) {
						// 校验
						if (!this.form.paymentAccount) {
							uni.showToast({
								title: '请填写您本人实名的支付宝账号/银行卡号',
								icon: 'none'
							})
							this.loading = false;
							return;
						}
						if (this.form.gameId !== null && this.gameOptions[this.form.gameId].id != 14) {
							if (!this.form.parentsName) {
								uni.showToast({
									title: '请填写第一联系人真实姓名',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.isName(this.form.parentsName)) {
								uni.showToast({
									title: '请填写正确的第一联系人真实姓名',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.form.parentsContact) {
								uni.showToast({
									title: '请填写第一联系人常用手机号',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.isPhone(this.form.parentsContact)) {
								uni.showToast({
									title: '请填写正确的第一联系人常用手机号',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (this.form.parentsRel === null) {
								uni.showToast({
									title: '请选择第一联系人与您的关系',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.form.friendsName) {
								uni.showToast({
									title: '请填写第二联系人真实姓名',
									icon: 'none'
								})
								this.loading = false;
								return;
							}

							if (!this.isName(this.form.friendsName)) {
								uni.showToast({
									title: '请填写正确的第二联系人真实姓名',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.form.friendsContact) {
								uni.showToast({
									title: '请填写第二联系人常用手机号',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (!this.isPhone(this.form.friendsContact)) {
								uni.showToast({
									title: '请填写正确的第二联系人常用手机号',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
							if (this.form.friendsRel === null) {
								uni.showToast({
									title: '请选择第二联系人与您的关系',
									icon: 'none'
								})
								this.loading = false;
								return;
							}
						}

						let formData = {
							orderId: this.form.orderId,
							inputMethod: 0,
							paymentAccount: this.form.paymentAccount
						}

						if (this.form.gameId !== null && this.gameOptions[this.form.gameId].id != 14) {
							formData.friendsContact = this.form.friendsContact
							formData.friendsName = this.form.friendsName
							formData.friendsRel = this.friendsRelOptions[this.form.friendsRel].id
							formData.parentsContact = this.form.parentsContact
							formData.parentsName = this.form.parentsName
							formData.parentsRel = this.parentsRelOptions[this.form.parentsRel].id
						}

						const that = this;

						sellerFill(formData).then(res => {
							sellerSubmit(formData).then(res => {
								uni.redirectTo({
									url: '/pages/empty/empty?account=' + that.delEmpty(that.form
										.account)
								})
							}).catch((err) => {
								that.loading = false;
							})
						}).catch((err) => {
							that.loading = false;
						})
					}
				} else {
					if (this.step == 2 || this.step == 3) {
						this.step--;
						this.loading = false;
					}
				}
			},
			// 游戏列表
			getGameOptions(data) {
				getGameArea().then(res => {
					if (res[1]) {
						this.gameOptions = res[1].data;
						this.setForm(data);
					}
				})
			},
			// 游戏选择
			gameOptionsChange(e) {
				this.form.gameId = e.detail.value;
			},
			// 获取游戏名称
			getGameName() {
				if (this.form.gameId !== null) {
					return this.gameOptions[this.form.gameId].name;
				} else {
					return '请选择游戏';
				}
			},
			// 账号来源
			accountSourceOptionsChange(e) {
				this.form.accountSource = e.detail.value;
			},
			// 获取账号来源
			getAccountSourceName() {
				if (this.form.accountSource !== null) {
					return this.accountSourceOptions[this.form.accountSource].name;
				} else {
					return '请选择账号来源';
				}
			},
			// 账号安全
			safetyOptionsChange(e) {
				this.form.safety = e.detail.value;
			},
			// 获取账号安全
			getSafetyName() {
				if (this.form.safety !== null) {
					return this.safetyOptions[this.form.safety].name;
				} else {
					return '请选择是否能对账号安全负责';
				}
			},
			// 第一联系人关系
			parentsRelOptionsChange(e) {
				this.form.parentsRel = e.detail.value;
			},
			// 获取第一联系人关系
			getParentsRelName(e) {
				if (this.form.parentsRel !== null) {
					return this.parentsRelOptions[this.form.parentsRel].name;
				} else {
					return '请选择与您的关系';
				}
			},
			// 第二联系人关系
			friendsRelOptionsChange(e) {
				this.form.friendsRel = e.detail.value;
			},
			// 获取第二联系人关系
			getFriendsRelName(e) {
				if (this.form.friendsRel !== null) {
					return this.friendsRelOptions[this.form.friendsRel].name;
				} else {
					return '请选择与您的关系';
				}
			},
			uploadIdCard(type) {
				try {
					const that = this;
					uni.chooseImage({
						count: 1,
						success(filePath) {
							uni.showLoading({
								title: '正在上传中',
								mask: true
							})
							if (type == 1) {
								// 正面
								// uni.uploadFile({
								// 	url: `${that.url}/file/scanIdCard`,
								// 	file: filePath.tempFiles[0],
								// 	name: 'file',
								// 	success(e) {
								// 		let parseData = JSON.parse(e.data);
								// 		if (parseData.code == 200) {
								// 			let imageData = JSON.parse(parseData.msg);
								// 			switch (imageData.image_status) {
								// 				case 'normal':
								// 					// 正常
								// 					that.form.sellerName = imageData.words_result['姓名']
								// 						.words;
								// 					that.form.idCardNumber = imageData.words_result[
								// 						'公民身份号码'].words;
								// 					that.form.idCardAddress = imageData.words_result['住址']
								// 						.words;

								// 					uni.uploadFile({
								// 						url: `${that.url}/file/upload`,
								// 						file: filePath.tempFiles[0],
								// 						name: 'file',
								// 						success(fileRes) {
								// 							if (fileRes.statusCode == 200) {
								// 								let fileData = JSON.parse(fileRes
								// 									.data);
								// 								that.form.idImageFont = fileData
								// 									.msg;
								// 							} else {
								// 								uni.showToast({
								// 									title: '出现错误,请重新上传5',
								// 									icon: 'none'
								// 								})
								// 							}
								// 							uni.hideLoading();
								// 						},
								// 						fail(err) {
								// 							uni.showToast({
								// 								title: '出现错误,请重新上传4',
								// 								icon: 'none'
								// 							})
								// 							uni.hideLoading();
								// 						}
								// 					})

								// 					break;
								// 				case 'reversed_side':
								// 					// 身份证正反面颠倒
								// 					uni.showToast({
								// 						icon: 'none',
								// 						title: '身份证正反面颠倒'
								// 					})
								// 					uni.hideLoading();
								// 					break;
								// 				case 'non_idcard':
								// 					// 上传的图片中不包含身份证
								// 					uni.showToast({
								// 						icon: 'none',
								// 						title: '上传的图片中不包含身份证'
								// 					})
								// 					uni.hideLoading();
								// 					break;
								// 				case 'blurred':
								// 					// 身份证模糊
								// 					uni.showToast({
								// 						icon: 'none',
								// 						title: '身份证模糊'
								// 					})
								// 					uni.hideLoading();
								// 					break;
								// 				case 'other_type_card':
								// 					// 其他类型证照
								// 					uni.showToast({
								// 						icon: 'none',
								// 						title: '其他类型证照'
								// 					})
								// 					uni.hideLoading();
								// 					break;
								// 				case 'over_exposure':
								// 					// 身份证关键字段反光或过曝
								// 					uni.showToast({
								// 						icon: 'none',
								// 						title: '身份证关键字段反光或过曝'
								// 					})
								// 					uni.hideLoading();
								// 					break;
								// 				case 'over_dark':
								// 					// 身份证欠曝（亮度过低）
								// 					uni.showToast({
								// 						icon: 'none',
								// 						title: '身份证欠曝（亮度过低）'
								// 					})
								// 					uni.hideLoading();
								// 					break;
								// 				case 'unknown':
								// 					// 出现错误请重新上传
								// 					uni.showToast({
								// 						icon: 'none',
								// 						title: '出现错误请重新上传3'
								// 					})
								// 					uni.hideLoading();
								// 					break;
								// 				default:
								// 					break;
								// 			}
								// 		} else {
								// 			uni.showToast({
								// 				title: '出现错误,请重新上传3',
								// 				icon: 'none'
								// 			})
								// 			uni.hideLoading();
								// 		}
								// 	},
								// 	fail(err) {
								// 		uni.showToast({
								// 			title: '出现错误,请重新上传2',
								// 			icon: 'none'
								// 		})
								// 		uni.hideLoading();
								// 	}
								// })
								uni.uploadFile({
									url: `${that.url}/file/upload`,
									file: filePath.tempFiles[0],
									name: 'file',
									success(fileRes) {
										if (fileRes.statusCode == 200) {
											let fileData = JSON.parse(fileRes.data);
											
											scanIdCard2({
												filePath: fileData.msg
											}).then(res => {
												let imgData = JSON.parse(res[1].msg);
												switch (imgData.code){
													case '10000':
														that.form.idImageFont = fileData.msg;
														uni.hideLoading();
														that.form.sellerName = imgData.data.name;
														that.form.idCardNumber = imgData.data.idcard;
														that.form.idCardAddress = imgData.data.address;
														break;
													case "10002":
														uni.showToast({
															title: '参数错误',
															icon: 'none'
														})
														uni.hideLoading();
														break;
													case "10005":
														uni.showToast({
															title: '服务器异常',
															icon: 'none'
														})
														uni.hideLoading();
														break;
													case "10008":
														uni.showToast({
															title: '查询失败',
															icon: 'none'
														})
														uni.hideLoading();
														break;
													case "10010":
														uni.showToast({
															title: '图片识别失败',
															icon: 'none'
														})
														uni.hideLoading();
														break;
													default:
														uni.showToast({
															title: '出现错误,请重新上传7',
															icon: 'none'
														})
														uni.hideLoading();
														break;
												}
											}).catch((err) => {
												uni.showToast({
													title: '出现错误,请重新上传6',
													icon: 'none'
												})
												uni.hideLoading();
											})
										} else {
											uni.showToast({
												title: '出现错误,请重新上传5',
												icon: 'none'
											})
											uni.hideLoading();
										}
									},
									fail(err) {
										uni.showToast({
											title: '出现错误,请重新上传4',
											icon: 'none'
										})
										uni.hideLoading();
									},
									complete() {
										uni.hideLoading();
									}
								})
							} else {
								// 背面
								uni.uploadFile({
									url: `${that.url}/file/upload`,
									file: filePath.tempFiles[0],
									name: 'file',
									success(fileRes) {
										if (fileRes.statusCode == 200) {
											let fileData = JSON.parse(fileRes.data);
											that.form.idImageBack = fileData.msg;
											uni.hideLoading();
										} else {
											uni.showToast({
												title: '出现错误,请重新上传5',
												icon: 'none'
											})
											uni.hideLoading();
										}
									},
									fail(err) {
										uni.showToast({
											title: '出现错误,请重新上传4',
											icon: 'none'
										})
										uni.hideLoading();
									},
									complete() {
										uni.hideLoading();
									}
								})
							}
						},
						fail(e) {
							uni.showToast({
								title: '出现错误,请重新上传1',
								icon: 'none'
							})
						}
					})
				} catch (e) {
					//TODO handle the exception
					uni.showToast({
						title: '出现错误,请重新上传',
						icon: 'none'
					})
					uni.hideLoading();
				}
			},
			// 上传网购订单
			uploadImage(index) {
				const that = this;
				uni.chooseImage({
					count: 1,
					success(filePath) {
						uni.showLoading({
							title: '正在上传中',
							mask: true
						})
						// 背面
						uni.uploadFile({
							url: `${that.url}/file/upload`,
							file: filePath.tempFiles[0],
							name: 'file',
							success(fileRes) {
								if (fileRes.statusCode == 200) {
									let fileData = JSON.parse(fileRes.data);
									if (index === null) {
										// push
										that.form.orderImageUrl.push(fileData.msg);
									} else {
										// replace
										that.form.orderImageUrl.splice(index, 1, fileData.msg);
									}
								} else {
									uni.showToast({
										title: '出现错误,请重新上传5'
									})
								}
								uni.hideLoading();
							},
							fail(err) {
								uni.showToast({
									title: '出现错误,请重新上传4'
								})
								uni.hideLoading();
							}
						})
					},
					fail(e) {
						uni.showToast({
							title: '出现错误,请重新上传1'
						})
					}
				})
			},
			// 上传网购订单
			uploadRealNameImage(index) {
				const that = this;
				uni.chooseImage({
					count: 1,
					success(filePath) {
						uni.showLoading({
							title: '正在上传中',
							mask: true
						})
						// 背面
						uni.uploadFile({
							url: `${that.url}/file/upload`,
							file: filePath.tempFiles[0],
							name: 'file',
							success(fileRes) {
								if (fileRes.statusCode == 200) {
									let fileData = JSON.parse(fileRes.data);
									that.form.realNameImage = fileData.msg;
								} else {
									uni.showToast({
										title: '出现错误,请重新上传5'
									})
								}
								uni.hideLoading();
							},
							fail(err) {
								uni.showToast({
									title: '出现错误,请重新上传4'
								})
								uni.hideLoading();
							}
						})
					},
					fail(e) {
						uni.showToast({
							title: '出现错误,请重新上传1'
						})
					}
				})
			},
			/**
			 * @Description: 手机号校验
			 * @author: 李建鹏
			 * @createTime: 2023-08-17 11:58:38
			 */
			isPhone(phone) {
				if (!phone) return false;

				return /^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(phone.toString());
			},
			/**
			 * @Description: 姓名校验 最少两个字 并且允许·
			 * @author: 李建鹏
			 * @createTime: 2023-11-22 12:02:03
			 */
			isName(name) {
				if (!name) return false;

				return /^[\u4e00-\u9fa5·\s]{2,}$/.test(name.toString());
			},
			previewExp() {
				uni.previewImage({
					urls: [require('@/static/exp.jpg')]
				})
			}
		}
	}
</script>